package com.senlingspace.common.enums;

/**
 * 订单来源
 *
 * @author lebronjames
 * @date 2024/07/30
 */
public enum OrderSource {

    SHOP(10, "门店"),
    DOUYIN(20, "抖音"),
    MEITUAN(30, "美团"),
    MINI_PROGRAM(40, "小程序");

    private final int code;
    private final String description;

    OrderSource(int code, String description) {
        this.code = code;
        this.description = description;
    }


    public int getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public static OrderSource fromCode(int code) {
        for (OrderSource source : OrderSource.values()) {
            if (source.getCode() == code) {
                return source;
            }
        }
        throw new IllegalArgumentException("Unknown code: " + code);
    }

    @Override
    public String toString() {
        return description;
    }

}
